fix which-key--show-keymap for which-key-enable-extended-define-key
authorJiangbin Zhao <zhaojiangbin@gmail.com>
Sun, 23 May 2021 21:07:53 +0000 (14:07 -0700)
committerJiangbin Zhao <zhaojiangbin@gmail.com>
Sun, 23 May 2021 21:48:29 +0000 (14:48 -0700)
With which-key-enable-extended-define-key set to 't, given the keymap
and bindings below:

  (setq a-map (make-sparse-keymap))
  (bind-keys :map a-map
             ("a" . ("key 1" . command-1))
             ("b" . ("key b" . command-2)))

The output of (which-key--get-keymap-bindings a-map) was having
"unknown" as the key descriptions.

This change fixes it therefore allows the following to work as
expected:

(which-key--show-keymap "A map" a-map)

which-key.el

index 8b4c60fdee846d528b62c9450bf02a32cb58e1ec..c5652d803bd6b592d0f78f3850b238f388179090 100644 (file)
@@ -1823,6 +1823,9 @@ ones. PREFIX is for internal use and should not be used."
                 (setq bindings
                       (append bindings
                               (which-key--get-keymap-bindings def t key))))
+               ((and def (consp def))
+                (cl-pushnew (cons key-desc (car def))
+                            bindings :test (lambda (a b) (string= (car a) (car b)))))
                (t
                 (when def
                   (cl-pushnew